home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / shootemup / includes / math.h < prev    next >
Encoding:
Text File  |  2002-04-10  |  4.0 KB  |  140 lines

  1. ;------------------------------------------------------------------------------------
  2. ;Description:
  3. ;   Used in general to stop counters climbing to high
  4. ;
  5. ;Parameters:
  6. ;   veriable - counter
  7. ;   limit    - highest value the counter can obtain
  8. ;
  9. ;Returns:
  10. ;   if counter is not the highest it can obrain returns veriable
  11. ;   if not returns the limit of the counter
  12. ;
  13. ;Usage:
  14. ;    foo=foo+1
  15. ;   foo=Max(foo,120)
  16. ;   results in foo never being higher than 120
  17. ;------------------------------------------------------------------------------------
  18. Function Max(veriable,limit)
  19.     If veriable=>limit Then Return limit-1 Else Return veriable
  20. End Function
  21.  
  22. ;------------------------------------------------------------------------------------
  23. ;Description:
  24. ;   Used in general to stop counters climbing to low
  25. ;
  26. ;Parameters:
  27. ;   veriable - counter
  28. ;   limit    - lowest value the counter can obtain
  29. ;
  30. ;Returns:
  31. ;   if counter is not the lowest it can obrain returns veriable
  32. ;   if not returns the limit of the counter
  33. ;
  34. ;Usage:
  35. ;   foo=120
  36. ;    foo=foo-1
  37. ;   foo=min(foo,0)
  38. ;   results in foo never being lower than 0
  39. ;------------------------------------------------------------------------------------
  40. Function Min(veriable,limit)
  41.     If veriable<=limit Then Return limit+1 Else Return veriable
  42. End Function
  43.  
  44. ;------------------------------------------------------------------------------------
  45. ;Description:
  46. ;   Used in general to stop counters climbing to high but when they do they
  47. ;   are returned to 0
  48. ;
  49. ;Parameters:
  50. ;   veriable - counter
  51. ;   limit    - highest value the counter can obtain before beign sent to 0
  52. ;
  53. ;Returns:
  54. ;   if counter is not the highest it can obrain returns veriable
  55. ;   if not returns 0 limit of the counter
  56. ;
  57. ;Usage:
  58. ;    foo=foo+1
  59. ;   foo=limittop(foo,120)
  60. ;   results in foo getting to 120 but return to 0 when it does
  61. ;------------------------------------------------------------------------------------
  62. Function LoopTop(veriable,limit)
  63.     If veriable=>limit Then Return limit=0 Else Return veriable
  64. End Function
  65.  
  66. ;------------------------------------------------------------------------------------
  67. ;Description:
  68. ;   Used in general to stop counters climbing to low but when they do they
  69. ;   are returned to limit
  70. ;
  71. ;Parameters:
  72. ;   veriable - counter
  73. ;   limit    - lowest value the counter can obtain before beign sent to limit
  74. ;
  75. ;Returns:
  76. ;   if counter is not the lowest it can obrain returns veriable
  77. ;   if not returns the limit of the counter
  78. ;
  79. ;Usage:
  80. ;    foo=120
  81. ;    foo=foo-1
  82. ;   foo=limitbottom(foo,120)
  83. ;   results in foo getting to 0 but return to 120 when it does
  84. ;------------------------------------------------------------------------------------
  85. Function LoopBottom(veriable,limit)
  86.     If veriable<=0 Then Return limit Else Return veriable
  87. End Function
  88.  
  89. ;--------------------------------val()-----------------------------------**
  90. ;usage val(mode$,valeur$) ou val      
  91. ;    "%"|binaire
  92. ;     "$"|hexadecimal
  93. ;     ""|decimal    
  94. ;------------------------------------------------------------------------**
  95. Function val(t$,a$)
  96.         a$=Upper$(a$)
  97.         ; 
  98.         Select t$
  99.             Case""
  100.                 mul=10
  101.             Case"$"
  102.                 mul=16
  103.             Case"%"
  104.                 mul=2
  105.         End Select
  106.         ;
  107.         pow=Len(a$)-1
  108.         ram=0
  109.         For da = 1 To Len(a$)
  110.         value=Asc(Mid$(a$,da,1))-48 
  111.         Select t$
  112.             Case "$"
  113.             If value>9                
  114.                 value=value-7
  115.             EndIf
  116.         End Select
  117.         For b=1 To pow
  118.             value=value*mul
  119.         Next
  120.         pow=pow-1
  121.         ram=ram+value
  122.     Next
  123.     Return ram
  124. End Function
  125.  
  126. ;************************************************************************************
  127. ;------------------------------------------------------------------------------------
  128. ;Description:
  129. ;   This function does something cool
  130. ;
  131. ;Parameters:
  132. ;   a - This Parameter tells it what to do
  133. ;   b - This Parameter is what it acts upon
  134. ;
  135. ;Returns:
  136. ;   fish - Salmon maybe?
  137. ;
  138. ;Additional Comments:
  139. ;   See Blah2 for additional information.
  140. ;------------------------------------------------------------------------------------